package com.wenmingliang.blog.admin.controller;

import com.wenmingliang.blog.admin.model.params.PageParam;
import com.wenmingliang.blog.admin.service.PermissionService;
import com.wenmingliang.blog.admin.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.security.Permission;

@RestController
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private PermissionService permissionService;

    @PostMapping("/permission/permissionList")
    public Result permissionList(@RequestBody PageParam pageParam) {
      return  permissionService.listPermission(pageParam);
    }

    @PostMapping("/permission/add")
    public Result addPermission(@RequestBody com.wenmingliang.blog.admin.pojo.Permission permission) {

        return permissionService.add(permission);
    }
//    @PostMapping("/permission/update")
//    public Result updatePermission(@RequestBody com.wenmingliang.blog.admin.pojo.Permission permission) {
//
//        return permissionService.update(permission);
//    }

    @PostMapping("/permission/update")
    public Result updateMyselfPermissionById(@RequestBody com.wenmingliang.blog.admin.pojo.Permission permission) {

        return permissionService.updateMyselfPermissionById(permission);
    }

    @GetMapping("/permission/delete/{id}")
    public Result deletePermission(@PathVariable("id") Long id) {

        return permissionService.delete(id);
    }
}
